﻿{include file="public/header" /}
			<form method="post">
				<div class="panel admin-panel">
					<div class="panel-head"><strong>{:lang('currency')['list']}</strong></div>
					<div class="padding border-bottom">
						<script>
						//city 参数和回调
						var gid="{:input('get.gid')}";
						var cateid="{:input('get.cateid')}";
						var selectc=true;
						var selecta=false;
						function select_g(){
							location.href="{:url('/admin/service')}?gid="+gid;
						}
						function select_c(){
							location.href="{:url('/admin/service')}?gid="+gid+"&cateid="+cateid;
						}
						</script>
						<input type="button" class="button button-small checkall" name="checkall" checkfor="id" value="{:lang('currency')['all_select']}" />
						<a type="button" class="button button-small border-green" href="service/edit.html" />{:lang('currency')['add']}</a>
						<a id="select_del" type="button" class="button button-small border-red" href="#" />{:lang('currency')['del']}</a>
						---{include file="public/category" /}
						<a type="button" class="button button border-yellow search" href="#" />{:lang('label')['service']}{:lang('label')['search']}</a>
					</div>
					<table class="table table-hover">
						<tr>
							<th width="60">{:lang('label')['select']}</th>
							<!-- <th width="50">{:lang('label')['seller']}</th> -->
							<th width="120">{:lang('label')['category']}</th>
							<th width="120">{:lang('label')['title']}</th>
							<th width="50">{:lang('label')['price']}</th>
							<!-- <th width="200">{:lang('label')['service']}</th>
							<th width="100">{:lang('label')['flag']}</th> -->
							<th width="100">{:lang('label')['status']}</th>
							<th width="100">{:lang('label')['handle']}</th>
							<th width="50">排序值</th>
						</tr>
						{volist name="data" id="service"}
						<tr>
							<td >
								<input type="checkbox" name="id" value="{$service.id}" />
							</td>
							<!-- <td style="line-height:40px">{:get_name($service.uid)}</td> -->
							<td style="line-height:40px">{:get_catname($service.gid,$service.cateid)}</td>
							<td style="line-height:40px">{$service.title}</td>
							<td style="line-height:40px">{$service.price}</td>
							<!-- <td style="line-height:40px">{$service.service}</td>
							<td style="line-height:40px"><a data-id="{$service.id}" data-flag="{$service.flag}" data-flagtime="{if $service.flagtime}{$service.flagtime|date='Y-m-d',###}{/if}" class="flag button border-blue button-little" href="javascript:;">{:lang('label')['flag_'.$service.flag]}{if $service.flagtime} _至_ {$service.flagtime|date="Y-m-d",###}{/if}</a></td> -->
							<td style="line-height:40px">{if $service.status == "1"}<span class="icon-check text-sub">{:lang('currency')['status_1']}</span>{else}<span class="icon-times text-dot">{:lang('currency')['status_2']}</span>{/if}</td>
							<td style="line-height:40px"><a class="button border-blue button-little" href="service/edit.html?id={$service.id}">{:lang('currency')['edit']}</a> <a class="button border-red button-little" href="service/del.html?id={$service.id}&page={:input('get.page')}" onclick="if(confirm('{:lang('currency')['del']}?')){return true;}return false;">{:lang('currency')['del']}</a></td>
							<td style="line-height:40px;">
								<input type="number" value="{$service.sort}" min="0" onchange="save_sort('{$service.id}',this.value)" style="background: #f7f7f7;height: 30px;padding-left: 5px; width: 50px;border: 1px solid #ccc">
							</td>
						</tr>
						{/volist}
					</table>
					{include file="public/pages" /}
				</div>
			</form>
			<script>
			layer.config({
				extend: 'extend/layer.ext.js'
			});
			$('#select_del').click(function(){
				var str=""; 
				$("input:checkbox[name=id]:checked").each(function(){ 
					str+=$(this).val()+",";
				});
				if(str!=''){
					if(confirm('{:lang('currency')['del']}?')){location.href='{$Request.controller}/del.html?id='+str;}	
				}
			});
			$('.flag').click(function(){
				var id = $(this).attr("data-id");
				var oflag = $(this).attr("data-flag");
				var oflagtime = $(this).attr("data-flagtime");
				layer.open({
					title: "{:lang('label')['flag']}",
					content: "<div>{:lang('label')['flag']}: <select id='flag'><option value='0'>{:lang('label')['flag_0']}</option><option value='1'>{:lang('label')['flag_1']}</option><option value='2'>{:lang('label')['flag_2']}</option><option value='3'>{:lang('label')['flag_3']}</option><option value='4'>{:lang('label')['flag_4']}</option></select></div><br/><div>{:lang('label')['time']}: <input id='flagtime' type='date' value='"+oflagtime+"'/></div>",
					yes: function(layero, index){
						var flag = $("#flag").val();
						var flagtime = $("#flagtime").val();
						if(flag == oflag && flagtime == oflagtime){
							layer.close(layero);
						}else{
							if(flag>0 && !flagtime){
								alert("{:lang('label')['time']}{:lang('currency')['required']}");
							}else{
								if(flag <= 0){
									flagtime = "";
								}
								$.get("{:url('admin/service/flag')}?id="+id+"&flag="+flag+"&flagtime="+flagtime,function(data){
									layer.msg(data.msg);
									if(data.code=="success"){
										location.reload();
									}
								});
							}
						}
					},
					success: function(layero, index){
						$("#flag").find("option[value='"+oflag+"']").attr("selected",true);
					}
				}); 
			});
			$('.search').click(function(){
				layer.prompt({title:'{:lang('label')['service']}{:lang('label')['search']}'},function(val){
					location.href="{:url('/admin/service')}?title="+val;
				});
			});
            function save_sort(id,sort) {
                if(confirm('确认修改排序值？')){
                    $.post('__URL__/?edit=sort&id='+id+'&sort='+sort,{},function () {
                        layer.msg('修改成功');
                    })
                }
            }
			</script>
{include file="public/footer" /}